package task;

import java.util.HashSet;
import java.util.Map;

import org.eclipse.swt.graphics.ImageData;

public abstract class Task implements ITask {
	private HashSet<NeededPropertiesChangedHandler> handlers = null;
	public ImageData getImageData() {
		return null;
	}
	@Override
	public abstract String getDescription();
	@Override
	public String getName() {
		return this.getClass().getSimpleName();
	}
	@Override
	public abstract void run(Map<String, String> props);
	@Override
	public String[] neededProperties() {
		return new String[0];
	}
	@Override
	public void addNeededPropertiesChangedHandler(
			NeededPropertiesChangedHandler handler) {
			getHandlers().add(handler);
	}
	@Override
	public void removeNeededPropertiesChangedHandler(
			NeededPropertiesChangedHandler handler) {
		getHandlers().remove(handler);
	}
	protected HashSet<NeededPropertiesChangedHandler> getHandlers() {
		if (handlers == null) handlers = new HashSet<NeededPropertiesChangedHandler>();
		return handlers;
	}
	@Override
	public String getSignature() {
		String sign = getClass().getName() + ':' + getName();
		return sign;
	}
}
